package cupk;

public class Chessman {
    private String label;
    private int x;
    private int y;
    public Chessman(String label,int x,int y){
        this.label = label;
        this.x = x;
        this.y = y;
    }
    public String getLabel(){
        return this.label;
    }
    public  void setLabel(String label){
        this.label = label;
    }

    public int getX() {
        return x;
    }

    public void setX(int x) {
        this.x = x;
        System.out.println("棋子"+label+"位置移动到："+x+","+y);
    }

    public int getY() {
        return y;
    }

    public void setY(int y) {
        this.y = y;
        System.out.println("棋子"+label+"位置移动到："+x+","+y);
    }

    public ChessmanMemento save(){
        return new ChessmanMemento(this.label,this.x,this.y);
    }

    public void restore(ChessmanMemento memento){
        this.label = memento.getLabel();
        this.x = memento.getX();
        this.y = memento.getY();
        System.out.println("棋子"+label+"位置恢复到："+x+","+y);
    }
    public void display(){
        System.out.println("棋子"+label+"当前位置为："+x+","+y);
    }
}
